﻿/********************************************************************************************************************
* Author:	Christos Polydorou																						*
* Email:	std04237@di.uoa.gr																						*
* Purpose:	This script is used in order to create the stored procedure "usp_addcategory" that adds a new 		*
*			category for a user.																					*
********************************************************************************************************************/

CREATE PROCEDURE [dbo].[usp_addcategory]
	@userid bigint,
	@category_name nvarchar(50),
	@isprivate int
AS
	DECLARE @categoryid bigint

	INSERT INTO Categories
	VALUES(@category_name,@userid,@isprivate,'0','0',CURRENT_TIMESTAMP)

	SELECT @categoryid = ID
	FROM Categories
	WHERE Categories.Name = @category_name and Categories.Owner = @userid

RETURN @categoryid